#include("../../comm/ListHead.html")
<style>
    .menufirst{ color:green }
    .menusecond{ color:darkolivegreen }
    .menuthird{ color:#666666 }
    .menudesc{ color:red }
</style>
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title" style="width: 100%;float:left">
        <li lay-event="EditSysRole"><i class="layui-icon layui-icon-tabs"></i> 编辑角色</li>
        <li lay-event="SetRoleMenu"><i class="layui-icon layui-icon-list"></i> 角色菜单</li>
        <li class="layui-this"><i class="layui-icon layui-icon-set-sm"></i> 角色功能</li>
        <li lay-event="SetRoleUser"><i class="layui-icon layui-icon-username"></i> 角色人员</li>
    </ul>
</div>
<div class="">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md2 width-20">
            <div class="layui-card height-auto">
                <div id="tree_1" class="demo-tree demo-tree-box height-scoll" style=" height:calc(100vh - 60px)"></div>
            </div>
        </div>
        <div class="layui-col-md10 width-80">
            <div class="card-search SearchTable">
                <i class="layui-icon layui-icon-triangle-r"></i>
                根菜单 / <span id="titles" class="color_green">#(form.data.title)</span> / <span class=\"menudesc\">功能列表</span>
            </div>
            <div class="layui-card height-auto">
                <div class="layui-card-body">
                    <input type="hidden" name="menu_id" id="menu_id" value="#(form.data.menuid)"/>
                    <input type="hidden" name="role_id" id="role_id" value="#(form.data.role_id)"/>
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>
                    <script type="text/html" id="temp_is_log">
                        <input type="checkbox" lay-skin="primary" field="has_role" msg="设置记录日志" value="{{d.act_id}}" lay-filter="ChangeActivityRoleTag" {{ d.has_role ? 'checked' : '' }}>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<SCRIPT LANGUAGE="JavaScript">
    <!--
    layui.use(['myTree', 'myTool', 'myTable', 'form'], function () {
        myTree = layui.myTree, myTool = layui.myTool, form = layui.form;
        var $ = layui.$;
        treedata = #(form.data.tree);
        //树渲染
        treeindex = myTree.render({
            id: 'menutree', init: 'third_' + $("#menu_id").val(),
            data: treedata, onlyIconControl: false, showCheckbox: false
            , click: function (obj) {
                var data = obj.data;
                if (data.turn) {
                    menu_id = data.datas.menuid;
                    title = data.datas.title;
                    $("#menu_id").val(menu_id);
                    $("#titles").html(data.datas.titles);
                    tableindex.reload({where: {menu_id: menu_id, role_id: $("#role_id").val()}});
                }
            }
        });

        layui.util.event("lay-event", {
            SetRoleUser: function () {
                location.href = "SetRoleUser?role_id=" + $("#role_id").val();
            },
            SetRoleMenu: function () {
                location.href = "SetRoleMenu?role_id=" + $("#role_id").val();
            },
            EditSysRole: function () {
                location.href = "EditSysRole?role_id=" + $("#role_id").val();
            }
        });

        tableindex = layui.myTable.render({
            elem: '#table_1', url: 'SysMenuActivityListDataApi'
            , title: '列表', toolbar: false
            , height: 480
            , where: {menu_id: $("#menu_id").val(), role_id: $("#role_id").val()}
            , cols: [[
                {type: 'checkbox', width: 30, fixed: true}
                , {field: 'act_id', title: 'ID', width: 30, align: 'center'}
                , {field: 'act_name', title: '功能名称', width: 150}
                , {field: 'act_path', title: '功能路经', width: 320}
                , {field: 'act_desc', title: '备注'}
                , {field: 'is_log', title: '权限', width: 80, align: 'center', templet: '#temp_is_log'}
            ]]
            , page: true, limit: 10
            , serviceSort: true, initSort: {field: 'act_id', type: 'desc'}
            , editField: {url: 'ModifySysActivityFieldApi', key: 'act_id'}
        });
    });

    layui.form.on('checkbox(ChangeActivityRoleTag)', function (obj) {
        myTool.postMsg("ChangeActivityRoleApi", {act_id: this.value, role_id: $("#role_id").val(), msg: $(obj.elem).attr("msg")}, function (result) {
            layer.tips(result.msg, obj.othis);
        });
    });
    //-->
</SCRIPT>
#include("../../comm/Foot.html")